import 'dart:convert';
import 'package:azlistview/azlistview.dart';
import 'package:lx_widgets_library/utils/formart_util.dart';

class AreaModel extends ISuspensionBean {
  /// 国家/地区名称
  String? name;

  /// 国家/地区编码
  String? code;
  String? tagIndex;
  String? namePinyin;

  AreaModel({
    required this.name,
    this.code,
    this.tagIndex,
    this.namePinyin,
  });

  AreaModel.fromJson(Map<String, dynamic> json)
      : name = json['name'] ?? '',
        code = FormatUtils.getAreaCodeExceptZero(json['phone_code']);

  Map<String, dynamic> toJson() => {
        'name': name,
        'areaCode': code,
        'tagIndex': tagIndex,
        'namePinyin': namePinyin,
      };

  @override
  String getSuspensionTag() => tagIndex!;

  @override
  String toString() => json.encode(this);
}
